<template>
	<view class="content">
		<view class="con-bg"></view>
		<view class="desc-con">
			<image :src="$IMG_URL+'notice.png'" mode="widthFix" style="width: 688rpx;"></image>
		</view>
		<view class="desc-but" @click="show=true">我已阅读并继续</view>
		<u-popup :show="show" mode="bottom" :round="10" @close="show = false">
			<view class="pop-con">
				<view class="pop-title">选择挂号日期</view>
				<scroll-view scroll-y="true" class="scroll-y">
					<view class="user-list">
						<view class="user-item" :class="tabIndex===index?'active':''" v-for="(item,index) in dateList"
							:key="index" @click="selectTab(item,index)">
							<view>{{item.name}}</view>
							<view style="margin-top: 15rpx;">{{item.time}}</view>
						</view>
					</view>
				</scroll-view>
				<view class="book-buta">
					<u-button type="primary" text="预约挂号" @click="goPage"></u-button>

				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				tabIndex: 0,
				time: '',
				dateList: [],

			}
		},
		onLoad() {
			this.time = this.GetDateStr(0).time
			this.dateList = [{
					name: '今天',
					time: this.GetDateStr(0).time
				},
				{
					name: '明天',
					time: this.GetDateStr(1).time
				},
				{
					name: '后天',
					time: this.GetDateStr(2).time
				},
				{
					name: this.GetDateStr(3).week,
					time: this.GetDateStr(3).time
				},
				{
					name: this.GetDateStr(4).week,
					time: this.GetDateStr(4).time
				},
				{
					name: this.GetDateStr(5).week,
					time: this.GetDateStr(5).time
				},
				{
					name: this.GetDateStr(6).week,
					time: this.GetDateStr(6).time
				},
			]
		},
		methods: {
			GetDateStr(AddDayCount) {
				const chineseNums = ['日', '一', '二', '三', '四', '五', '六'];
				var dd = new Date();
				dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
				var y = dd.getFullYear();
				var m = ('0' + (dd.getMonth() + 1)).slice(-2); //获取当前月份的日期
				var d = ('0' + dd.getDate()).slice(-2);
				var week = dd.getDay()
				console.log(week);
				return {
					time: y + "-" + m + "-" + d,
					week: '星期' + chineseNums[week]
				}
			},
			selectTab(item, index) {
				this.tabIndex = index
				this.time = item.time
			},
			goPage() {
				this.show = false
				uni.navigateTo({
					url: `/pages/bookdepart/bookdepart?time=${this.time}`
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.content {
		height: 100%;
		padding-top: 23rpx;
		box-sizing: border-box;
	}

	.con-bg {
		position: fixed;
		top: 0;
		left: 0;
		z-index: 1;
		width: 100vw;
		height: 100%;
		background-image: url('#{$IMG_URL}bg_information_l.png');
		background-repeat: no-repeat;
		background-size: cover;
	}

	.desc-con {
		position: relative;
		z-index: 2;
		margin: 0 auto;
		width: 688rpx;
	}

	.desc-but {
		position: relative;
		z-index: 2;
		margin: 0 auto;
		margin-top: 90rpx;
		width: 688rpx;
		height: 85rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #05A2FF;
		font-size: 31rpx;
	}

	.pop-con {
		padding: 31rpx;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.pop-title {
		width: 100%;
		text-align: center;
		font-weight: 500;
		color: #000000;
		font-size: 31rpx;
	}

	.scroll-y {
		height: 470rpx;
		width: 688rpx;
		margin-top: 31rpx;
		box-sizing: border-box;
	}

	.user-list {

		margin-right: -31rpx;
		display: flex;
		flex-wrap: wrap;



	}

	.user-item {
		width: 215rpx;
		height: 138rpx;
		background: #F4F4F4;
		border-radius: 10rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		color: #000000;
		font-size: 27rpx;
		margin-bottom: 23rpx;
		margin-right: 21rpx;

	}

	.book-buta {
		width: 688rpx;
		height: 85rpx;
		margin: 0 auto;
		margin-top: 31rpx;
	}

	.active {
		border: 1px solid #05A2FF;
		background: #EDF8FF;
		color: #05A2FF;
		box-sizing: border-box;
	}
</style>